"ipp-versions-supported",
"multiple-document-handling-supported",
"copies-supported",
- "number-up-supported"
+ "number-up-supported",
+ "device-uri"
};
/* Attributes we're interested in for printers without PPD */
int number_of_covers;
gchar *output_bin_default;
GList *output_bin_supported;
+ gchar *original_device_uri;
} PrinterSetupInfo;
static void
printer_setup_info_free (PrinterSetupInfo *info)
{
+ g_free (info->original_device_uri);
g_free (info->state_msg);
g_strfreev (info->covers);
g_slice_free (PrinterSetupInfo, info);
info->output_bin_supported = g_list_reverse (info->output_bin_supported);
}
+ else if (g_strcmp0 (ippGetName (attr), "device-uri") == 0)
+ {
+ info->original_device_uri = g_strdup (ippGetString (attr, 0, NULL));
+ }
else
{
GTK_NOTE (PRINTING,
cups_printer->default_cover_before = g_strdup (info->default_cover_before);
cups_printer->default_cover_after = g_strdup (info->default_cover_after);
+ cups_printer->original_device_uri = g_strdup (info->original_device_uri);
if (info->default_number_up > 0)
cups_printer->default_number_up = info->default_number_up;
guint printer_state;
gchar *type;
gchar *domain;
+ gchar *UUID;
GtkPrintBackendCups *backend;
} AvahiConnectionTestData;
+static GtkPrinter *
+find_printer_by_uuid (GtkPrintBackendCups *backend,
+ const gchar *UUID)
+{
+ GtkPrinterCups *printer;
+ GtkPrinter *result = NULL;
+ GList *printers;
+ GList *iter;
+ gchar *printer_uuid;
+
+ printers = gtk_print_backend_get_printer_list (GTK_PRINT_BACKEND (backend));
+ for (iter = printers; iter != NULL; iter = iter->next)
+ {
+ printer = GTK_PRINTER_CUPS (iter->data);
+ if (printer->original_device_uri != NULL)
+ {
+ printer_uuid = g_strrstr (printer->original_device_uri, "uuid=");
+ if (printer_uuid != NULL && strlen (printer_uuid) >= 41)
+ {
+ printer_uuid += 5;
+ printer_uuid = g_strndup (printer_uuid, 36);
+
+#if GLIB_CHECK_VERSION(2, 52, 0)
+ if (g_uuid_string_is_valid (printer_uuid))
+#endif
+ {
+ if (g_strcmp0 (printer_uuid, UUID) == 0)
+ {
+ result = GTK_PRINTER (printer);
+ g_free (printer_uuid);
+ break;
+ }
+ }
+
+ g_free (printer_uuid);
+ }
+ }
+ }
+
+ g_list_free (printers);
+
+ return result;
+}
+
/*
* Create new GtkPrinter from informations included in TXT records.
*/
set_info_state_message (info);
printer = gtk_print_backend_find_printer (GTK_PRINT_BACKEND (data->backend), data->printer_name);
+
+ if (printer == NULL && data->UUID != NULL)
+ printer = find_printer_by_uuid (data->backend, data->UUID);
+
if (printer == NULL)
{
printer = cups_create_printer (data->backend, info);
if (data->printer_state != 0 || endptr != value)
data->got_printer_state = TRUE;
}
+ else if (g_strcmp0 (key, "UUID") == 0)
+ {
+ if (*value != '\0')
+ data->UUID = g_strdup (value);
+ }
g_clear_pointer (&key, g_free);
g_clear_pointer (&value, g_free);